gl renderer: Save rectilinearity in clip stack
authorTimm Bäder <mail@baedert.org>
Fri, 24 Jul 2020 16:30:36 +0000 (18:30 +0200)
committerTimm Bäder <mail@baedert.org>
Tue, 28 Jul 2020 03:34:12 +0000 (05:34 +0200)
So we don't have to repeatedly call it in pop_clip()

gsk/gl/gskglrenderops.c
gsk/gl/gskglrenderopsprivate.h

index bcee21a6596825d597149cb2868e27d033aedfce..0a59026577b3fd3eace517ca7f89b3dbc5c59e86 100644 (file)
@@ -1,6 +1,12 @@
 #include "gskglrenderopsprivate.h"
 #include "gsktransform.h"
 
+typedef struct
+{
+  GskRoundedRect rect;
+  bool is_rectilinear;
+} ClipStackEntry;
+
 static inline gboolean
 rect_equal (const graphene_rect_t *a,
             const graphene_rect_t *b)
@@ -310,33 +316,37 @@ void
 ops_push_clip (RenderOpBuilder      *self,
                const GskRoundedRect *clip)
 {
+  ClipStackEntry entry;
+
   if (G_UNLIKELY (self->clip_stack == NULL))
-    self->clip_stack = g_array_new (FALSE, TRUE, sizeof (GskRoundedRect));
+    self->clip_stack = g_array_new (FALSE, TRUE, sizeof (ClipStackEntry));
 
   g_assert (self->clip_stack != NULL);
 
-  g_array_append_val (self->clip_stack, *clip);
-  self->current_clip = &g_array_index (self->clip_stack, GskRoundedRect, self->clip_stack->len - 1);
-  self->clip_is_rectilinear = gsk_rounded_rect_is_rectilinear (self->current_clip);
+  entry.rect = *clip;
+  entry.is_rectilinear = gsk_rounded_rect_is_rectilinear (clip);
+  g_array_append_val (self->clip_stack, entry);
+  self->current_clip = &g_array_index (self->clip_stack, ClipStackEntry, self->clip_stack->len - 1).rect;
+  self->clip_is_rectilinear = entry.is_rectilinear;
   ops_set_clip (self, clip);
 }
 
 void
 ops_pop_clip (RenderOpBuilder *self)
 {
-  const GskRoundedRect *head;
+  const ClipStackEntry *head;
 
   g_assert (self->clip_stack);
   g_assert (self->clip_stack->len >= 1);
 
   self->clip_stack->len --;
-  head = &g_array_index (self->clip_stack, GskRoundedRect, self->clip_stack->len - 1);
+  head = &g_array_index (self->clip_stack, ClipStackEntry, self->clip_stack->len - 1);
 
   if (self->clip_stack->len >= 1)
     {
-      self->current_clip = head;
-      self->clip_is_rectilinear = gsk_rounded_rect_is_rectilinear (self->current_clip);
-      ops_set_clip (self, head);
+      self->current_clip = &head->rect;
+      self->clip_is_rectilinear = head->is_rectilinear;
+      ops_set_clip (self, &head->rect);
     }
   else
     {
index 0a8bf557f9ac4f000d97f8981a93395ec47e791f..de8b30ddd9964952785bc43b14072eafa24c2748 100644 (file)
@@ -188,7 +188,7 @@ typedef struct
   GArray *clip_stack;
   /* Pointer into clip_stack */
   const GskRoundedRect *current_clip;
-  guint clip_is_rectilinear;
+  bool clip_is_rectilinear;
 } RenderOpBuilder;